﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerCheckpoint : MonoBehaviour
{
    [HideInInspector] public MapCheckpoint checkPoint;
    public MapCheckpoint StartCheckpoint;

    private void Start()
    {
        if (StartCheckpoint == null)
        {
            Debug.LogError("没有设置初使存档点，每个场景都需要设置一个初始存档点。建议使用Prefab:Assets/Props/Start Checkpoint.prefab");
        }
    }


    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.R) && checkPoint != null) 
            checkPoint.Spawn(gameObject);

    }

    public void ReturnToCheckpoint()
    {
        if (checkPoint != null)
            checkPoint.Spawn(gameObject);
        else
            StartCheckpoint.Spawn(gameObject);
    }

}
